#pragma once

#include <linux/spinlock_types_raw.h>

typedef struct
{
    union
    {
        struct raw_spinlock rlock;
    };
} spinlock_t;

#define ___SPIN_LOCK_INITIALIZER(lockname)     \
    {                                          \
        .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \
    }

#define __SPIN_LOCK_INITIALIZER(lockname)               \
    {                                                   \
        {                                               \
            .rlock = ___SPIN_LOCK_INITIALIZER(lockname) \
        }                                               \
    }

#define __SPIN_LOCK_UNLOCKED(lockname) \
    (spinlock_t) __SPIN_LOCK_INITIALIZER(lockname)

#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
